#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "queue.h"
#include "printf.h"
extern void led_flash_loop();
TaskHandle_t led_taskhandle, mutex_hanle;
void task_mutex();
SemaphoreHandle_t mutex;
void freertos_start()
{

    mutex = xSemaphoreCreateMutex();
    xSemaphoreGive(mutex);
    xTaskCreate(&led_flash_loop, "led", 256, NULL, 2, &led_taskhandle);
    xTaskCreate(&task_mutex, "mutex", 2048, NULL, 3, &mutex_hanle);
    vTaskStartScheduler();
}

void task_mutex()
{

    while (1)
    {
        if (xSemaphoreTake(mutex, 0xffffffffUL))
        {
            printf("task mutex\r\n");
            xSemaphoreGive(mutex);
        }
        vTaskDelay(5000);
    }
}